/*     */ package com.zimbra.cs.filter;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.filter.jsieve.ActionFlag;
/*     */ import com.zimbra.cs.mailbox.DeliveryOptions;
/*     */ import com.zimbra.cs.mailbox.Folder;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.mailbox.Message;
/*     */ import com.zimbra.cs.mailbox.OperationContext;
/*     */ import com.zimbra.cs.mime.ParsedMessage;
/*     */ import com.zimbra.cs.service.util.ItemId;
/*     */ import java.io.IOException;
/*     */ import java.util.Collection;
/*     */ import java.util.List;
/*     */ import javax.mail.MessagingException;
/*     */ import javax.mail.internet.MimeMessage;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class OutgoingMessageHandler
/*     */   implements FilterHandler
/*     */ {
/*     */   private ParsedMessage parsedMessage;
/*     */   private Mailbox mailbox;
/*     */   private int defaultFolderId;
/*     */   private boolean noICal;
/*     */   private int defaultFlags;
/*     */   private String[] defaultTags;
/*     */   private int convId;
/*     */   private OperationContext octxt;
/*     */   
/*     */   public OutgoingMessageHandler(Mailbox mailbox, ParsedMessage pm, int sentFolderId, boolean noICal, int flags, String[] tags, int convId, OperationContext octxt)
/*     */   {
/*  52 */     this.mailbox = mailbox;
/*  53 */     this.parsedMessage = pm;
/*  54 */     this.defaultFolderId = sentFolderId;
/*  55 */     this.noICal = noICal;
/*  56 */     this.defaultFlags = flags;
/*  57 */     this.defaultTags = tags;
/*  58 */     this.convId = convId;
/*  59 */     this.octxt = octxt;
/*     */   }
/*     */   
/*     */   public Message getMessage()
/*     */   {
/*  64 */     return null;
/*     */   }
/*     */   
/*     */   public MimeMessage getMimeMessage()
/*     */   {
/*  69 */     return this.parsedMessage.getMimeMessage();
/*     */   }
/*     */   
/*     */   public int getMessageSize()
/*     */   {
/*     */     try {
/*  75 */       return this.parsedMessage.getMimeMessage().getSize();
/*     */     } catch (Exception e) {
/*  77 */       ZimbraLog.filter.warn("Error in determining message size", e); }
/*  78 */     return -1;
/*     */   }
/*     */   
/*     */ 
/*     */   public ParsedMessage getParsedMessage()
/*     */   {
/*  84 */     return this.parsedMessage;
/*     */   }
/*     */   
/*     */   public String getDefaultFolderPath()
/*     */     throws ServiceException
/*     */   {
/*  90 */     return this.mailbox.getFolderById(this.octxt, this.defaultFolderId).getPath();
/*     */   }
/*     */   
/*     */   public Message explicitKeep(Collection<ActionFlag> flagActions, String[] tags) throws ServiceException
/*     */   {
/*     */     try {
/*  96 */       DeliveryOptions dopt = new DeliveryOptions().setFolderId(this.defaultFolderId).setConversationId(this.convId);
/*  97 */       dopt.setFlags(FilterUtil.getFlagBitmask(flagActions, this.defaultFlags));
/*  98 */       dopt.setTags(FilterUtil.getTagsUnion(tags, this.defaultTags));
/*  99 */       dopt.setNoICal(this.noICal);
/* 100 */       return this.mailbox.addMessage(this.octxt, this.parsedMessage, dopt, null);
/*     */     } catch (IOException e) {
/* 102 */       throw ServiceException.FAILURE("Unable to add sent message", e);
/*     */     }
/*     */   }
/*     */   
/*     */   public void redirect(String destinationAddress)
/*     */     throws ServiceException
/*     */   {
/* 109 */     FilterUtil.redirect(this.octxt, this.mailbox, this.parsedMessage.getOriginalMessage(), destinationAddress);
/*     */   }
/*     */   
/*     */   public void reply(String bodyTemplate)
/*     */   {
/* 114 */     ZimbraLog.filter.debug("Ignoring attempt to reply to outgoing message");
/*     */   }
/*     */   
/*     */ 
/*     */   public void notify(String emailAddr, String subjectTemplate, String bodyTemplate, int maxBodyBytes, List<String> origHeaders)
/*     */     throws ServiceException, MessagingException
/*     */   {
/* 121 */     FilterUtil.notify(this.octxt, this.mailbox, this.parsedMessage, emailAddr, subjectTemplate, bodyTemplate, maxBodyBytes, origHeaders);
/*     */   }
/*     */   
/*     */   public Message implicitKeep(Collection<ActionFlag> flagActions, String[] tags)
/*     */     throws ServiceException
/*     */   {
/* 127 */     return explicitKeep(flagActions, tags);
/*     */   }
/*     */   
/*     */   public ItemId fileInto(String folderPath, Collection<ActionFlag> flagActions, String[] tags)
/*     */     throws ServiceException
/*     */   {
/* 133 */     return FilterUtil.addMessage(null, this.mailbox, this.parsedMessage, null, folderPath, this.noICal, FilterUtil.getFlagBitmask(flagActions, this.defaultFlags), FilterUtil.getTagsUnion(tags, this.defaultTags), this.convId, this.octxt);
/*     */   }
/*     */   
/*     */   public void discard() {}
/*     */   
/*     */   public void beforeFiltering() {}
/*     */   
/*     */   public void afterFiltering() {}
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/filter/OutgoingMessageHandler.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */